﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;

namespace KTX
{
    public partial class frmHopDongDaKy : DevExpress.XtraEditors.XtraForm
    {
        public frmHopDongDaKy()
        {
            InitializeComponent();
        }

        Data.QLKTXEntities db = new Data.QLKTXEntities();
        private void frmHopDongDaKy_Load(object sender, EventArgs e)
        {
            dayNhaBindingSource.DataSource = db.DayNha;

        }

        private void searchLookUpEdit1_EditValueChanged(object sender, EventArgs e)
        {
            if (searchLookUpEdit1.EditValue!=null)
            {
                var day = (int)searchLookUpEdit1.EditValue;
                hopDongBindingSource.DataSource = db.HopDong.ToList().Where(p => p.NgayKetThucHD > DateTime.Now && p.Phong.MaNha == day);
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (searchLookUpEdit1.EditValue != null)
            {
                var day = (int)searchLookUpEdit1.EditValue;
                hopDongBindingSource.DataSource = db.HopDong.ToList().Where(p => p.NgayKetThucHD > DateTime.Now && p.Phong.MaNha == day);
            }
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            var report = new BaoCao.xDanhSachHopDong();
            BindingSource bs = (BindingSource)report.DataSource;
            bs.DataSource = hopDongBindingSource.List;
            report.ShowPreviewDialog();
        }
    }
}